// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SmsThread.java

package net.sms;

import com.oa.database.DataConn;
import java.io.PrintStream;
import java.util.Collection;
import java.util.Iterator;

// Referenced classes of package net.sms:
//            SmsItem, SmsItemInfo, SMSSender

public class SmsThread
    implements Runnable
{

    static boolean isRuning = false;
    private DataConn dataConn;
    private Iterator iterSms;
    private SmsItem smsItem;
    private static String strSQL = "FSBZ=0 order by DXID ASC";
    private SmsItemInfo smsItemInfo;
    private int iCom;
    private int iDXID;
    private String mobile;
    private String content;
    private int iFlag;
    private static boolean booleanStop = false;
    public static boolean runing = false;

    public SmsThread()
    {
        dataConn = null;
        iterSms = null;
        smsItem = null;
        smsItemInfo = null;
        iCom = 1;
        iDXID = 0;
        mobile = null;
        content = null;
        iFlag = 0;
        dataConn = new DataConn();
        smsItem = new SmsItem(dataConn);
    }

    public void SetCom(int intCom)
    {
        iCom = intCom;
    }

    public static void SetStop()
    {
        booleanStop = true;
    }

    public void run()
    {
        if(!isRuning)
        {
            isRuning = true;
            try
            {
                while(!booleanStop) 
                {
                    if(iterSms == null || !iterSms.hasNext())
                        iterSms = smsItem.getList(strSQL).iterator();
                    while(iterSms != null && iterSms.hasNext()) 
                    {
                        smsItemInfo = (SmsItemInfo)iterSms.next();
                        if(smsItemInfo != null)
                        {
                            mobile = smsItemInfo.getJSRSJ();
                            content = smsItemInfo.getDXBT();
                            System.out.println(content + "=====" + mobile);
                            if(SMSSender.SendSms(iCom, (mobile + "\0").getBytes(), (content + "\0").getBytes(), (content + "\0").getBytes().length) == 0)
                                iFlag = 1;
                            else
                                iFlag = 2;
                            smsItem.updateFlag(iDXID, iFlag);
                        }
                    }
                    Thread.sleep(5000L);
                }
            }
            catch(Exception exception) { }
        }
    }

    public static void main(String args[])
    {
        SmsThread smsThread1 = new SmsThread();
    }

}
